import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import article from '@/views/article/article.vue'
import publishArticle from '@/views/article/publishArticle.vue'

//解决多次点击跳转时报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    children:[
      {
        path:'article',
        component: article
      },
      {
        path:'publishArticle',
        component:publishArticle
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (login.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: function () {
      return import(/* webpackChunkName: "login" */ '../views/login.vue')
    }
  }
]

const router = new VueRouter({
  routes
})

export default router
